package com.lin.project.cloudnative.service.impl;
import java.util.Date;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lin.project.cloudnative.common.ErrorCode;
import com.lin.project.cloudnative.enums.PostGenderEnum;
import com.lin.project.cloudnative.enums.PostReviewStatusEnum;
import com.lin.project.cloudnative.exception.BusinessException;
import com.lin.project.cloudnative.model.entity.TestCase;
import com.lin.project.cloudnative.service.TestCaseService;
import com.lin.project.cloudnative.mapper.TestCaseMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
* @author 林怀旭
* @description 针对表【test_case(测试用例)】的数据库操作Service实现
* @createDate 2023-11-12 21:36:48
*/
@Service
public class TestCaseServiceImpl extends ServiceImpl<TestCaseMapper, TestCase>
    implements TestCaseService{

    @Override
    public void validTestCase(TestCase testCase, boolean add) {
        if(testCase==null){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        Long id = testCase.getId();
        String language = testCase.getLanguage();
        String code = testCase.getCode();
        String remark = testCase.getRemark();
        String result = testCase.getResult();
        Integer time = testCase.getTime();
        String type = testCase.getType();
        Integer status = testCase.getStatus();
        //创建时，所有参数必须非空
        if(add){
            if(StringUtils.isAnyBlank(language,code)){
                throw new BusinessException(ErrorCode.PARAMS_ERROR);
            }
        }
//        if(StringUtils.isNotBlank(code) && code.length() > 8192){
//            throw new BusinessException(ErrorCode.PARAMS_ERROR,"代码过长");
//        }
//        if(language!=null && !PostReviewStatusEnum.getValues().contains(reviewStatus)){
//            throw new BusinessException(ErrorCode.PARAMS_ERROR);
//        }
//        if(age!=null && (age<18 || age>100)){
//            throw new BusinessException(ErrorCode.PARAMS_ERROR,"年龄不符合要求");
//        }
//        if(gender!=null && !PostGenderEnum.getValues().contains(gender)){
//            throw new BusinessException(ErrorCode.PARAMS_ERROR,"年龄不符合要求");
//        }
    }
}




